package servlets;
import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import utility.UserSession;

public class QuestionSubmission extends HttpServlet{
	String message;
public QuestionSubmission(){
	super();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{
	
        response.setContentType("text/html");
        String question=request.getParameter("ques");
        String optionA=request.getParameter("ans1");
        String optionB=request.getParameter("ans2");
        String optionC=request.getParameter("ans3");
        String optionD=request.getParameter("ans4");
        String option=request.getParameter("correctans");
        UserSession sess = new UserSession();
        message=sess.addQuestion(question,optionA,optionB,optionC,optionD,option);
        if(message.equals("Success"))
        {
       	 request.setAttribute("message", "Thank you for submitting a question. Good job!!");
       	RequestDispatcher RequestDispatcherObj =request.getRequestDispatcher("/view/UserHome.jsp");
        RequestDispatcherObj.forward(request, response);
        }
        else
        {
       	 request.setAttribute("message", message);
        }
}
}